import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import store from './store'

const app = createApp(App)

app.use(ElementPlus)
app.use(router)
app.use(store)

// 确保 DOM 加载完成后再挂载
document.addEventListener('DOMContentLoaded', () => {
  app.mount('#app')
})

// 开发环境下输出调试信息
if (process.env.NODE_ENV === 'development') {
  console.log('Vue app initialization started')
  app.config.errorHandler = (err) => {
    console.error('Vue Error:', err)
  }
  app.config.warnHandler = (msg) => {
    console.warn('Vue Warning:', msg)
  }
}

const { electronAPI } = window

// 使用 electronAPI 替代 Node.js API
const joinPath = (...args) => electronAPI.path.join(...args) 